# -*- coding: utf-8 -*-
#!/usr/local/bin/python
# Author: yuxiangyu
# Date: Aug 16, 2021 9:25 PM
# =============================

'''
celery 配置
'''
from __future__ import absolute_import, unicode_literals

from celery import Celery, platforms
from django.conf import settings
import os

# settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'modelProject.settings')
# redis url
# redis_url = 'redis://127.0.0.1:6379/2'
redis_url = 'redis://:Unidt%402022@110.40.211.150:8998/8'
# app = Celery('untitled', broker='redis://:Woysb@127.0.0.1:6379/0', backend='redis://:Woysb@127.0.0.1:6379/0')
# 计算结果存储在 redis 中
# app = Celery('model-woyoushiban', broker=redis_url, backend=redis_url)
# 计算结果存储 django db 中
app = Celery('model', broker=redis_url, backend='django-db')

# read conf of celery from settings.py
app.config_from_object('django.conf:settings', namespace='CELERY')

# load auto tasks
app.autodiscover_tasks()

# 允许root 用户运行celery
platforms.C_FORCE_ROOT = True

# expires time
# result_expires = 60  # 默认 1 天

